<?php
/**
 * Created by PhpStorm.
 * User: lxd
 * Date: 2018/7/25
 * Time: 16:16
 * Comm:
 */

require './start.php';

$param      = json_decode( $_POST['payment_method_nonce'], true );


/**
 * create card
 */
$customerId     = $param['details']['payerId'];
$result         = $gateway->creditCard()->create( [
    'customerId'    => $customerId,
    'number'        => '4111111111111111',
    'expirationDate'    => '06/22',
    'cvv'           => 100
] );
var_dump( $result );
/**
 * create card end
 */


/**
 * amount  必填，数字，二位小数
 *
 *
 */
//$data   = [
//    'amount'        => 100,
//    'paymentMethodNonce'    => $_POST['payment_method_nonce'],
//];
//
//$res    = $gateway->transaction()->sale( $data );
//
//if( $res->success ) {
//    $trans      = $res->transaction;
//    $tid        = $trans->id;
//
//    var_dump( $gateway->transaction()->find( $tid ) );
//}else
//    var_dump( $res->errors->deepAll() );